# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

draw_chart_forecast_test = (rows_data)->
  data = new google.visualization.DataTable()
  data.addColumn 'number', 'Time'
  data.addColumn 'number', 'Duration'
  data.addColumn 'number', 'Forecast'
  data.addRows rows_data
   
  options = 
    title:'Forecast vs Real Time Series Chart'
    legend: 'none'
    vAxis:
      title: 'Duration in Minutes'
    hAxis:
      gridlines:
        count: -1
                    
  chart = new google.visualization.LineChart document.getElementById('forecast_test_result_chart')
  chart.draw data, options
  
$(document).ready ->
  drawAllCharts = ->
    url_params = 'test_log_id=' + test_log_id
    
    $.getJSON '/test_forecast_result_chart_data?' + url_params, (json_data) ->
      draw_chart_forecast_test json_data
      
  window.test_log_id = $.url().param 'test_log_id'
  google.load 'visualization', '1.0', {'packages':['corechart'], 'callback' : drawAllCharts}